<!DOCTYPE html>
<html>
<head>
    <#assign secSelect = JspTaglibs["http://www.casic304.cn/secSelect"]/>
    <#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
    <meta charset="utf-8">
    <title>质量综合分析报告 基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <style>
        .qbdms-TBinformation{margin-left: 0px;}
        .qbdms-TBinformationText{margin-left: 145px;}
    </style>
    <#if isClose == 'true'>
    <style>
        .listBody .qbdms-bodyDiv{padding: 0 }
        body.qbdms-particulars .qbdms-bodyDiv div.layui-table-view-body{padding: 16px}
       .treeFormPreview{position: unset;padding-left: 30px}
    </style>
</#if>
</head>
<body class="listBody qbdms-particulars" >
<div class="qbdms-bodyDiv">
    <div class="qbdms-backDiv">
        <div class="layui-table-view-body" style="padding: 0 24px 24px;">
            <#if isClose != 'true'> <div class="qbdms-formTitle" style="border-bottom: 1px solid #E5F0FF"><span id="titleTD">质量综合分析报告</span> <i class="qbdms-returnOn closeWindow">返回</i></div></#if>
            <form class="treeFormPreview layui-form" requrl="${ctx}/qbdms/wQbdQualityAnalysisReport/get" lay-filter="wQbdQualityAnalysisReportDataForm" >
                <div class="" style="width: 100%;overflow-x: auto">
                    <table class="tableExcel qbdms-zeroTable" width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr id="tbxx"></tr>
                            <tr>
                                <td class="qbdms-zeroTable-lable">密级<span style="color: red;">*</span></td>
                                <td colspan="5"><@secSelect.sec_select data_src=1 required=true name="secret"/></td>
                            </tr>
                            <tr>
                                <td class="qbdms-zeroTable-lable">年度<span style="color: red;">*</span></td>
                                <td colspan="5" name="year"></td>
                            </tr>
                            <tr id="leibie">
                                <td class="qbdms-zeroTable-lable">类别<span style="color: red;">*</span></td>
                                <td colspan="5"><@dicSelect.dic name="type" nodeKey="bglb"/></td>
                            </tr>
                            <tr>
                                <td class="qbdms-zeroTable-lable">报告名称<span style="color: red;">*</span></td>
                                <td colspan="5" name="name"></td>
                            </tr>
                            <tr>
                                <td class="qbdms-zeroTable-lable">附件<span style="color: red;">*</span></td>
                                <td colspan="5"><div class="uploadFileList" fileUploadName="attachmentUrl"></div></td>
                            </tr>
                            <tr>
                                <td class="qbdms-zeroTable-lable">备注</td>
                                <td colspan="5" name="remark"></td>
                            </tr>
                        </tbody>
                    </table>
                    <input id="year" type="hidden" name="year"  placeholder="请输入"  lay-verify="required" lay-reqtext="年度是必填项" autocomplete="off" class="layui-input textInput" maxlength="50" fieldname="year">
                </div>
                <#if isClose != 'true'>
                    <div class="layui-form-item btnformItem">
                        <p>
                            <button type="reset" id="closeWindow" class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">返回</button>
                        </p>
                    </div>
                </#if>
                <!--<div class="layui-row">
                    <div id="tbxx"></div>
                    <div style="width: 40%">
                        <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@secSelect.sec_select data_src=1 required=true name="secret"/>
                        </div>
                    </div>
                    <div style="width: 40%">
                        <label class="layui-form-label qbdms-label"  title="年度">年度<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input id="year" type="text" name="year"  placeholder="请输入"  lay-verify="required" lay-reqtext="年度是必填项"
                                   autocomplete="off" class="layui-input textInput"
                                   maxlength="50" fieldname="year">
                        </div>
                    </div>
                    <div style="width: 40%" id="leibie">
                        <label class="layui-form-label qbdms-label"  title="类别">类别<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@dicSelect.dic name="type" nodeKey="bglb" verify="required" reqtext="类别是必填项"/>
                        </div>
                    </div>
                    <div style="width: 70%">
                        <label class="layui-form-label qbdms-label"  title="报告名称">报告名称<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <input type="text" name="name"  placeholder="请输入" lay-verify="required" lay-reqtext="报告名称是必填项"
                                   autocomplete="off" class="layui-input textInput " maxlength="50" fieldname="name">
                        </div>
                    </div>
                    <div >
                        <label class="layui-form-label qbdms-label" title="附件">附件<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <div class="doNotDelThisDiv layui-input-inline">
                                <div class="uploadFileCont">
                            <button type="button" class="layui-btn iconfont iconupload fileUpload qbdms-fileUp" > 上传附件</button>
                            <i class="qbdms-fileUpText">支持单个附件上传，附件格式：doc  docx  pdf，附件大小限制：100M</i>
                            <input type="text" id="attachmentUrl" class="uploadInput" name="attachmentUrl" lay-verify="required" lay-reqtext="附件是必填项"
                                   fieldname="attachmentUrl" style="display: none">
                            <div class="uploadFileList" fileUploadName="attachmentUrl"></div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div style="width: 76%">
                        <label class="layui-form-label qbdms-label" title="备注">备注</label>
                        <div class="layui-input-block qbdms-input">
                            <textarea  name="remark" rows="2" class="layui-textarea" placeholder="请输入"
                                       autocomplete="off" class="layui-input textInput" style="height: 77px" maxlength="500" fieldname="remark"></textarea>
                        </div>
                    </div>
                </div>

                <div class="layui-hide">
                    <input type="text" name="id" placeholder="请输入"
                           autocomplete="off" class="layui-input " maxlength="50" fieldname="id">
                </div>-->
            </form>
        </div>
    </div>
</div>
</div>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'setter', 'layer', 'propsHandle', 'common', 'laydate', 'jquery','publicMethods'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            propsHandle = layui.propsHandle,
            publicMethods = layui.publicMethods,
            setter = layui.setter,  // 配置信息
            layer = layui.layer,
            defProps = {
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle()  // 实例化模板功能部分
        ;
        // 初始化模板功能
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        var common = layui.common;
        var dateTimeFiledLen = $(".dateTimeFiled");
        for (var i = 0; i < dateTimeFiledLen.length; i++) {
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                , type: 'date'
                , trigger: 'click'
            });
        }

        //年度选择
        laydate.render({
            elem: '#year' //指定元素
            , type: 'year'
            , value: publicMethods.timeData(new Date(),3)
            , min: '2019-1-1'
            , trigger: 'click'
        });

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            if ("${isClose}" == "true") {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            }
            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQualityAnalysisReport/view/list'+'${backHos}';
        });

        var runId = "${runId}";
        if (runId == null || runId == '') {
            $("#hideAndShow").show();
        }

        var index = parent.layer.getFrameIndex(window.name);

        common.updateForm({
            name: 'wQbdQualityAnalysisReportDataForm',
            idValue: "${id}",
            primary: "id",
            beforeSubmitFun: function (data) {
                //- 附件密级不能高于表单密级 开始 ------------------------------------------------------
                var selectMaxVal = 0;
                var formSecretVal = $("[name='secret']").val();
                $(".fileSecLevel select").each(function () {
                    selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
                });

                if (selectMaxVal > formSecretVal) {
                    layer.msg('附件密级不能高于表单密级。', {icon: 5});
                    return false;
                }
                //- 附件密级不能高于表单密级 结束 ------------------------------------------------------

                $(".uploadFileList").each(function (i,v) {
                    common.constructFileStr(v)
                });

                var files=[];
                //整理上传附件的隐藏域，将提交的字符串转为json对象
                $(".uploadInput").each(function () {
                    var uploadName = $(this).attr("name");
                    if (!$(this).val()) {
                        return;
                    }
                    data.field[uploadName] = eval($(this).val());
                    files=files.concat(eval($(this).val()));
                });

                return common.setFileLevel(files);

            },
            getCallback: function (data) {
                $("#tbxx").html("<td class='qbdms-zeroTable-lable'>填报信息:</td><td colspan='5' class=''>【" + data.data.filldept + " | " + data.data.fillman + " | " + data.data.filldate + "】</td>");
                // $("#tbxx").html("<span class='qbdms-TBinformation'>填报信息:</span><span class='qbdms-TBinformationText'>【" + data.data.filldept + " | " + data.data.fillman + " | " + data.data.filldate + "】</span>");

                var baseTitle=$("#titleTD").text();
                if(data.data.reportStatus==''){
                    $("#leibie").hide();
                    $("#titleTD").text('集团级'+baseTitle);
                }else {
                    $("#titleTD").text('院级'+baseTitle);
                }

                //-修改页面 初始化附件组件 开始 ------------------------------------------
                $('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);

                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel fileSecXg layui-input-inline">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '">' + fileSec + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont" style="margin-right: 5px"></i>' + files[i].fileName + '</span></span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                            $(this).find("select:last").attr("disabled", "disabled");
                        }
                    } else {
                        $(this).html("<span style='color: #c0c4cc'>未上传</span>");
                    }
                });
                /*$('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);
                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel fileSecXg layui-input-inline" style="float: left;margin: 8px 0 0;">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '"><span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont iconlink" style="margin-right: 5px"></i>' + files[i].fileName + '</span>' + fileSec + '</span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                            $(this).find("select:last").attr("disabled", "disabled");
                        }
                    }
                });*/
                //-修改页面 初始化附件组件 结束 ------------------------------------------
            }
        });

        //-- 附件上传 开始 --------------------------------------------------------------
        /*var secSelect = '<@secSelect.sec_select data_src=1 hasBlank=false/>'
        common.uploadfun(".fileUpload",'${wjszsdsxlx}',"${fileManagementUploadType}",secSelect,false);*/
        //下载附件
        window.downFile = function (obj) {
            var fileId = $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId=" + fileId;
        }
        //-- 附件上传 结束 --------------------------------------------------------------

        var isClose = '${isClose}'
        if(isClose=="true"){
            $(".closeWindow").hide()
        }
        $("body *").not("#closeWindow").attr("disabled","disabled");
        $(".uploadFileCont .qbdms-fileUp,.uploadFileCont i,.addFormTr1").hide();
        $(".uploadFileCont").each(function () {
            if ($(this).children('.uploadFileList').children().length==0){
                $(this).children('.uploadFileList').append("<span style='color: #C0C4CC'>未上传</span>")
            }
        })
    });
</script>
</body>
</html>